package com.kbs.im.server.bootstrap;

import com.kbs.im.common.protocol.codec.PacketCodecHandler;
import com.kbs.im.common.protocol.codec.Spliter;
import com.kbs.im.server.handler.HeartbeatRequestHandler;
import com.kbs.im.server.handler.IMHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * 服务pipline配置类
 *
 * @author zhangzhang
 */
public class ImServerChannelInitializer extends ChannelInitializer<NioSocketChannel> {

    static final ImServerChannelInitializer INSTANCE = new ImServerChannelInitializer();


    @Override
    protected void initChannel(NioSocketChannel ch) throws Exception {
        //消息魔数校验
        ch.pipeline().addLast(new Spliter());
        //自定义协议的编解码器
        ch.pipeline().addLast(PacketCodecHandler.INSTANCE);
//        ch.pipeline().addLast(new TestHandler());
        ch.pipeline().addLast(new HeartbeatRequestHandler());
        ch.pipeline().addLast(IMHandler.INSTANCE);
    }
}
